@include('admin::layouts.header')
<div class="admin-main layui-anim layui-anim-upbit">
    <fieldset class="layui-elem-field layui-field-title">
        <legend>操作日志</legend>
    </fieldset>
	<div class="demoTable layui-row">
		<div class="layui-form layui-form-pane" style="float:left;">
			<div class="layui-form-item">
				<label class="layui-form-label">管理员</label>
				<div class="layui-input-inline layui-form">
					<input class="layui-input" name="username" id="username" placeholder="请输入管理员">
				</div>
			</div>
        </div>
		<div class="layui-form layui-form-pane" style="float:left;">
			<div class="layui-form-item">
				<label class="layui-form-label">操作路径</label>
				<div class="layui-input-inline layui-form">
					<input class="layui-input" name="key" id="key" placeholder="请输入操作路径">
				</div>
			</div>
        </div>
		<div class="layui-form layui-form-pane" style="float:left;width:460px">
			<div class="layui-form-item">
				<label class="layui-form-label">操作时间</label>
				<div style="width:72%" class="layui-input-inline layui-form">
					<input style="width:100%" type="text" class="layui-input" id="created_at" placeholder="请选择时间">
				</div>
			</div>	
		</div>
		<div class="layui-form layui-form-pane" style="float:left">
			<div class="layui-form-item">
				<label class="layui-form-label">状态</label>
				<div class="layui-input-inline layui-form">
					<select id="status_d">
						<option value="">请选择</option>
						@foreach($status_lists as $key=>$value)
							<option value="{{$key}}">{{$value}}</option>
						@endforeach
					</select>
				</div>
			</div>		
		</div>
    </div>
	<div class="demoTable layui-row">
		<button class="layui-btn" style="margin-left:30px;margin-top:15px;" id="search" data-type="reload">查询</button>
		<a href="{{route('admin.operation_log.index')}}" style="margin-top:15px;" class="layui-btn">重置</a>
	</div>
    <table class="layui-table" id="list" lay-filter="list"></table>
</div>
@include('admin::layouts.footer')
<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>
<script type="text/html" id="status">
	@{{# if(d.status==1){ }}
        <span>@{{d.status_name}}</span>
	@{{# }else{  }}
		<span style="color:red;">@{{d.status_name}}</span>	
	@{{# } }} 
</script>
<script type="text/html" id="url">
	
       <a href="@{{d.url}}" target="_blank">@{{d.url}}</a>
	
</script>
<script type="text/html" id="topBtn">
   <button type="button" class="layui-btn layui-btn-sm layui-btn-danger" onclick="delAll()">批量删除</button>
</script>
<script>
    layui.use(['table','form'], function() {
        var table = layui.table,form = layui.form,$ = layui.jquery;
        var tableIn = table.render({
			id: 'ad',
            elem: '#list',
            url: "{{route('admin.operation_log.data')}}",
            method:'get',
			toolbar: '#topBtn',
			title:'操作日志',
			page: true,
            cols: [[
				{checkbox: true, fixed: true}
                ,{field:'id', title: '编号', width:100,align: 'center',fixed: true,sort: true}
                ,{field:'admin_name', title: '操作管理员',align: 'center', width:150}
                ,{field:'name', title: '操作名称',align: 'center', width:200}
                ,{field:'url', title: '请求路径',align: 'center', width:400,toolbar:'#url'}
                ,{field:'methods', title: '请求方式',align: 'center', width:100}
                ,{field:'ip', title: '操作IP',align: 'center', width:150}
                ,{field:'status_name', title: '操作状态',align: 'center', width:100,toolbar:'#status'}
                ,{field:'created_at', title: '操作时间',align: 'center', width:200,sort: true}
                ,{width:100, title: '操作',align:'center',align: 'center', toolbar: '#barDemo'} 
            ]],
			limit: "{!! config('admin.common_limit') !!}"
        });
		//搜索
        $('#search').on('click', function () {
			var created_at 		= $('#created_at').val();
			var status  		= $('#status_d').val();
			var key  			= $('#key').val();
			var username  	    = $('#username').val();
            if ($.trim(created_at) === '' && $.trim(status) === '' && $.trim(key) === '' && $.trim(username) === ''){
                layer.msg("{!! config('admin.query_condition') !!}", {icon: 0});
                return;
            }
			tableIn.reload({
				where: {created_at:created_at,status:status,key:key,username:username}
			});
        });
    });
</script>
@include('admin::layouts.delete_ajax',['url'=>route('admin.operation_log.destroy')])
@include('admin::layouts.delete_all_ajax',['url'=>route('admin.operation_log.destroy_all')])
</body>
</html>